package com.cci.kangdao.controller.wwidFleet;

import com.cci.kangdao.service.WwidFleetService;
import com.cci.kangdao.utilTool.ParameterTool;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
@Controller
public class WwidFleetController {
    private Logger log = Logger.getLogger(this.getClass().getName());

    @Autowired
    private WwidFleetService wwidFleetService;
    /**
     * wwid 用户设备列表接口
     * @param request
     * @return
     */
    @RequestMapping("/getCustomerEngineRelByKeyWord.aspx")
    public ModelAndView getCustomerEngineRelByKeyWord(HttpServletRequest request,
                                                      HttpServletResponse response){
        try{
            Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
            map.put("response", response);
            map.put("request", request);
            return wwidFleetService.getCustomerEngineRelByKeyWord(map);
        }catch(Exception ex){
            log.error(ex.getMessage(),ex);

            String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
            ParameterTool.writeResponse(response, msg);
        }
        return null;
    }

    /**
     * wwid 用户设备列表接口-------获取销售实体，平台,排放等级
     * @param request
     * @return
     */
    @RequestMapping("/getSearchParams.aspx")
    public ModelAndView getSearchParams(HttpServletRequest request,
                                        HttpServletResponse response){
        try{
            Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
            map.put("response", response);
            map.put("request", request);
            return wwidFleetService.getSearchParams(map);
        }catch(Exception ex){
            log.error(ex.getMessage(),ex);
            String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
            ParameterTool.writeResponse(response, msg);
        }
        return null;
    }

    /**
     *b端 wwid  获取车队列表
     * @param request
     * @return
     */
    @RequestMapping("/wwid/getfleetList")
    public ModelAndView getfleetList(HttpServletRequest request,
                                        HttpServletResponse response){
        try{
            Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
            map.put("response", response);
            map.put("request", request);
            return wwidFleetService.getfleetList(map);
        }catch(Exception ex){
            log.error(ex.getMessage(),ex);
            String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
            ParameterTool.writeResponse(response, msg);
        }
        return null;
    }

    /**
     *b端 wwid  获取esn列表接口
     * @param request
     * @return
     */
    @RequestMapping("/wwid/getEsnList")
    public ModelAndView getEsnList(HttpServletRequest request,
                                     HttpServletResponse response){
        try{
            Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
            map.put("response", response);
            map.put("request", request);
            return wwidFleetService.getEsnList(map);
        }catch(Exception ex){
            log.error(ex.getMessage(),ex);
            String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
            ParameterTool.writeResponse(response, msg);
        }
        return null;
    }
}
